package models

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserID  int64
	OrderSn string
	GoodsId int64
	Status  string
	PayType string
	Num     int64
	Total   float64
}

func (o *Order) Create() error {
	return DB.Create(o).Error
}

func (o *Order) GetOrderById() error {
	return DB.Where("id = ?", o.ID).Limit(1).Find(&o).Error
}

type OrderGoods struct {
	gorm.Model
	UserID     int64
	OrderID    int64
	OrderSn    string
	GoodsId    int64
	GoodsName  string
	GoodsPrice float64
	GoodsNum   int64
}

func (og *OrderGoods) CreateOG() error {
	return DB.Create(og).Error
}
